<!DOCTYPE html>
<HTML>
<HEAD><meta name="viewport" content="width=device-width, initial-scale=1">
<Title>TrendLayer</Title>
<link type='text/css' rel='Stylesheet' href="maxchartapi.css" />
</HEAD>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">

<p class="heading0">ChartDirector 7.0 (Java Edition)</p>
<p class="heading1">TrendLayer</p>
<hr class="separator">
<div class="content">
The TrendLayer class represents trend layers. TrendLayer is a subclass <a href="Layer.htm">Layer</a>.<br><br>
TrendLayer objects are created by using <a href="XYChart.addTrendLayer.htm">XYChart.addTrendLayer</a> and <a href="XYChart.addTrendLayer2.htm">XYChart.addTrendLayer2</a>.<br><br>
The trend layer performs regression analysis on the data points. It draws the optimal line or curve that fits the data points, with optional confidence and prediction bands.<br><br>
In regression analysis, a function with some unknown coefficients is chosen first. The "method of least squares" is used to estimate the coefficients, so that the function optimally fits the data points.<br><br>
In the most common case, the function chosen is a linear function with unknown slope and intercept (the unknown coefficients). Linear regression is used to determine the slope and intercept such that the line optimally fits the data points.<br><br>
The regression types supported by ChartDirector are listed below. They can be chosen using <a href="TrendLayer.setRegressionType.htm">TrendLayer.setRegressionType</a>. The default regression type is linear regression.<br><br>
<div style="width:100%;box-sizing:border-box;"><table width="100%" border="1" cellpadding="5" cellspacing="0"> <tr><th width="38%">Regression Type<th>Description
<tr><td>Linear<td>y = <i>a<sub>0</sub></i> + <i>a<sub>1</sub></i>x
<tr><td>Constrained Linear<td>y = <i>a<sub>1</sub></i>x
<tr><td>Polynomial<td>y = &#931;<i>a<sub>n</sub></i>x<sup>n</sup>
<tr><td>Exponential<td>y = e<sup><i>a<sub>0</sub></i> + <i>a<sub>1</sub></i>x</sup>
<tr><td>Logarithmic<td>y = <i>a<sub>0</sub></i> + <i>a<sub>1</sub></i>log(x)
</table></div><br>
The coefficients estimated by regression analysis are based on available data. They may be not equal to the "real" values, which are unknown. In ChartDirector, the uncertainties can be represented visually as a confidence band around the regression line. For example, a 95% confidence band means there is 95% probability that the real line is in that band. Confidence bands can be added to the chart using <a href="TrendLayer.addConfidenceBand.htm">TrendLayer.addConfidenceBand</a>.<br><br>
Even if the regression line is 100% accurate, data point may still not lie exactly on the line due to noise in the data. The prediction band is the region that the data points are likely to be found. For example, a 95% prediction band means there is 95% probability that a data point will be in that band. Prediction bands can be added to the chart using <a href="TrendLayer.addPredictionBand.htm">TrendLayer.addPredictionBand</a>.<br><br>
A prediction band is normally wider than and is at least as wide as the confidence band of the same probability. It is because the uncertainties of the data points are due to both the uncertainties of the regression line and the noise.
<br><br>
<div style="width:100%;box-sizing:border-box;">
<table border="1" cellpadding="5" cellspacing="0" width="100%"> 
<tr>
<th width="19%">Method</th><th width="19%">Inherited</th><th>Description</th>
</tr>
<tr>
<td><a href="TrendLayer.setRegressionType.htm">setRegressionType</a></td><td>(Self)</td><td>Sets the regression type to be used.</td></tr><tr><td><a href="TrendLayer.addConfidenceBand.htm">addConfidenceBand</a></td><td>(Self)</td><td>Adds a confidence band to the trend layer.</td></tr><tr><td><a href="TrendLayer.addPredictionBand.htm">addPredictionBand</a></td><td>(Self)</td><td>Adds a prediction band to the trend layer.</td></tr><tr><td><a href="TrendLayer.getSlope.htm">getSlope</a></td><td>(Self)</td><td>Gets the slope of the trend line. The method is only defined if the regression type is linear or constrained linear.</td></tr><tr><td><a href="TrendLayer.getIntercept.htm">getIntercept</a></td><td>(Self)</td><td>Gets the y-axis intercept of the trend line. The method is only defined if the regression type is linear.</td></tr><tr><td><a href="TrendLayer.getCoefficient.htm">getCoefficient</a></td><td>(Self)</td><td>Gets the coefficients of the regression function.</td></tr><tr><td><a href="TrendLayer.getCorrelation.htm">getCorrelation</a></td><td>(Self)</td><td>Gets the correlation coefficient of the trend line.</td></tr><tr><td><a href="TrendLayer.getStdError.htm">getStdError</a></td><td>(Self)</td><td>Gets the standard error of the trend line.</td></tr><tr><td><a href="TrendLayer.setImageMapWidth.htm">setImageMapWidth</a></td><td>(Self)</td><td>Sets the effective width of the line used for producing image maps.</td></tr><tr><td><a href="TrendLayer.getLine.htm">getLine</a></td><td>(Self)</td><td>Retrieves an opaque LineObj representing the trend line. The opaque LineObj is to be used in <a href="XYChart.addInterLineLayer.htm">XYChart.addInterLineLayer</a> for adding coloring between lines.</td></tr><tr><td><a href="Layer.set3D.htm">set3D</a></td><td>Layer</td><td>Sets the 3D depth of the layer, and the 3D gap between the current layer and the next layer.</td></tr><tr><td><a href="Layer.setLineWidth.htm">setLineWidth</a></td><td>Layer</td><td>Sets the default line width of lines when drawing data sets on the layer.</td></tr><tr><td><a href="Layer.setBorderColor.htm">setBorderColor</a></td><td>Layer</td><td>Sets the default border color and lighting effect for the data representation.</td></tr><tr><td><a href="Layer.setLegendOrder.htm">setLegendOrder</a></td><td>Layer</td><td>Sets the order of the data set names as appeared in the legend box.</td></tr><tr><td><a href="Layer.setLegend.htm">setLegend</a></td><td>Layer</td><td>Sets the order of the data set names as appeared in the legend box.</td></tr><tr><td><a href="Layer.getLegendIcon.htm">getLegendIcon</a></td><td>Layer</td><td>Gets the CDML representation of the legend icon for a data set.</td></tr><tr><td><a href="Layer.setDataCombineMethod.htm">setDataCombineMethod</a></td><td>Layer</td><td>Sets the method used to combine multiple data sets in a layer.</td></tr><tr><td><a href="Layer.addDataSet.htm">addDataSet</a></td><td>Layer</td><td>Adds a data set to the chart layer.</td></tr><tr><td><a href="Layer.getDataSet.htm">getDataSet</a></td><td>Layer</td><td>Gets a <a href="DataSet.htm">DataSet</a> object based on the order in which it is being added to the chart.</td></tr><tr><td><a href="Layer.getDataSetByZ.htm">getDataSetByZ</a></td><td>Layer</td><td>Gets a <a href="DataSet.htm">DataSet</a> object based on the order in which it is being drawn.</td></tr><tr><td><a href="Layer.getDataSetCount.htm">getDataSetCount</a></td><td>Layer</td><td>Gets the number of data sets in the layer.</td></tr><tr><td><a href="Layer.addDataGroup.htm">addDataGroup</a></td><td>Layer</td><td>Open a new data group.</td></tr><tr><td><a href="Layer.addExtraField.htm">addExtraField</a></td><td>Layer</td><td>Adds an array of text to be used as an extra field in various places.</td></tr><tr><td><a href="Layer.addExtraField2.htm">addExtraField2</a></td><td>Layer</td><td>Adds an array of numbers/dates to be used as an extra field in various places.</td></tr><tr><td><a href="Layer.setUseYAxis.htm">setUseYAxis</a></td><td>Layer</td><td>Determine the y-axis to use when drawing the data sets.</td></tr><tr><td><a href="Layer.setUseYAxis2.htm">setUseYAxis2</a></td><td>Layer</td><td>Determine if the primary or secondary y-axis should be used when drawing the data sets.</td></tr><tr><td><a href="Layer.setXData.htm">setXData</a></td><td>Layer</td><td>Sets the x values of the data points in the data sets.</td></tr><tr><td><a href="Layer.setXData2.htm">setXData2</a></td><td>Layer</td><td>Sets the x values of the data points in the data sets as evenly distributed in a range.</td></tr><tr><td><a href="Layer.setBaseLine.htm">setBaseLine</a></td><td>Layer</td><td>Sets the baseline for the data representation.</td></tr><tr><td><a href="Layer.alignLayer.htm">alignLayer</a></td><td>Layer</td><td>Aligns the layer with a data set of another bar chart layer in <a href="Chart.Side.htm">Side</a> layout.</td></tr><tr><td><a href="Layer.getXCoor.htm">getXCoor</a></td><td>Layer</td><td>Gets the x pixel coordinate given the x data value.</td></tr><tr><td><a href="Layer.getYCoor.htm">getYCoor</a></td><td>Layer</td><td>Gets the y pixel coordinate given the y data value.</td></tr><tr><td><a href="Layer.getNearestXValue.htm">getNearestXValue</a></td><td>Layer</td><td>Gets the x data value that is nearest to the specified x pixel coordinate.</td></tr><tr><td><a href="Layer.getXIndexOf.htm">getXIndexOf</a></td><td>Layer</td><td>Gets the data point index at the specified x data value.</td></tr><tr><td><a href="Layer.getXPosition.htm">getXPosition</a></td><td>Layer</td><td>Gets the x positional value of a data point, as measured on the primary x-axis.</td></tr><tr><td><a href="Layer.xZoneColor.htm">xZoneColor</a></td><td>Layer</td><td>Creates an x-zone color. An x-zone color will change from one color to another depending on a threshold value on the x-axis.</td></tr><tr><td><a href="Layer.yZoneColor.htm">yZoneColor</a></td><td>Layer</td><td>Creates a y-zone color. A y-zone color will change from one color to another depending on a threshold value on the y-axis.</td></tr><tr><td><a href="Layer.setDataLabelStyle.htm">setDataLabelStyle</a></td><td>Layer</td><td>Enables data labels and sets their styles.</td></tr><tr><td><a href="Layer.setDataLabelFormat.htm">setDataLabelFormat</a></td><td>Layer</td><td>Sets the data label format.</td></tr><tr><td><a href="Layer.addCustomDataLabel.htm">addCustomDataLabel</a></td><td>Layer</td><td>Adds a custom data label to a data point.</td></tr><tr><td><a href="Layer.setAggregateLabelStyle.htm">setAggregateLabelStyle</a></td><td>Layer</td><td>Enables aggregate labels and sets their styles.</td></tr><tr><td><a href="Layer.setAggregateLabelFormat.htm">setAggregateLabelFormat</a></td><td>Layer</td><td>Sets the aggregate label format.</td></tr><tr><td><a href="Layer.addCustomAggregateLabel.htm">addCustomAggregateLabel</a></td><td>Layer</td><td>Adds a custom aggregate label to an aggregated object.</td></tr><tr><td><a href="Layer.addCustomGroupLabel.htm">addCustomGroupLabel</a></td><td>Layer</td><td>Adds a custom data group label to object representing the group.</td></tr><tr><td><a href="Layer.moveFront.htm">moveFront</a></td><td>Layer</td><td>Moves the layer in front of another layer.</td></tr><tr><td><a href="Layer.moveBack.htm">moveBack</a></td><td>Layer</td><td>Moves the layer behind another layer.</td></tr><tr><td><a href="Layer.getImageCoor.htm">getImageCoor</a></td><td>Layer</td><td>Gets the image map coordinates of a data point as represented in the layer as HTML image map attributes.</td></tr><tr><td><a href="Layer.getImageCoor2.htm">getImageCoor2</a></td><td>Layer</td><td>Gets the image map coordinates of a region containing all data points at the given x-position as HTML image map attributes.</td></tr><tr><td><a href="Layer.getHTMLImageMap.htm">getHTMLImageMap</a></td><td>Layer</td><td>Generates an HTML image map for all data points as represented on the layer.</td></tr><tr><td><a href="Layer.setHTMLImageMap.htm">setHTMLImageMap</a></td><td>Layer</td><td>Override the default arguments used when generating HTML image map for the layer.</td>
</tr>
</table>
</div>

</div>
<hr class="separator"><div class="copyright">&copy; 2022 Advanced Software Engineering Limited. All rights reserved.</div>
</body>
</HTML>
